
<style>
.affix{top:10px;}
.head-style-list li,.editor-template-list li{cursor: pointer;}
.questions{padding:10px 0;margin-top:10px;color:#333;border-bottom:2px dashed #999}
table{width:100%;border-spacing:2px;border-collapse: separate;margin:0px;padding:0px;}

tr.active{background-color: #d9d9d9;}
tr.correct{background-color: #dff0d8;border-color: #d6e9c6;color: #468847;}
td,th{padding:5px 0px;border:0 none;}
label{cursor: pointer;}
.btn-primary{background-color: #0c9794;font-size:20px;color:#FFF;}
h3,h4,.ui-state-default{color:#0c9794;line-height: 1.6em;}
.ui-widget-content {
    background-color: transparent;
    border: 0 none;
}
h4{cursor:move;}
.ui-state-default{border: 0 none;}
.operates{display:none;}
.questions:hover .operates{display:block;}
</style>
		<div class="ui-portlet">
			<ol class="breadcrumb">
			  <li><a href="/users/index"><i class="fa fa-home"></i>&nbsp;&nbsp;个人中心</a></li>
			  <li><a href="/questionnaires/mine">我的数据表单</a></li>
			  <li class="active">编辑表单</li>
			</ol> 
		</div>          
       <hr>

	
		
	<div class="tab-content">
		<div role="tabpanel" class="tab-pane active" id="chi-info">
			<h2>{{$Questionnaire['name']}}</h2>
		</div>
		
		<p>
		
		<a class="btn btn-default btn-sm" target="_blank" href="/questionnaires/form/{{$Questionnaire['creator']}}/{{$Questionnaire['id']}}"><i class="fa fa-eye"></i> 查看表单提交页面</a>&nbsp;&nbsp;
		<a class="btn btn-default btn-sm" href="/questionnaires/edit/{{$Questionnaire['id']}}"><i class="fa fa-pencil"></i> 编辑名称与描述</a>
		</p>
		<div class="alert alert-warning">
		提示：
		<p style="text-indent:2em;">表单提交页可直接用于分享，收集数据。</p>
		<p style="text-indent:2em;">点击标题拖动，可调整各项的前后顺序</p>
		</div>       				
	</div>
	<hr>
	<a onclick="return publishController.open_dialog(this.href,{id:'questionnaire-form',title:'新增填空表单项','width':'860px',submitCallback:function(){reloadQuestionList();}});" class="btn btn-primary" href="/surveys/add?questiontype=input&referer=false&questionnaire_id={{$Questionnaire['id']}}"><i class="fa fa-plus"></i> 填空</a>
	<a onclick="return publishController.open_dialog(this.href,{id:'questionnaire-form',title:'新增单选表单项','width':'860px',submitCallback:function(){reloadQuestionList();}});" class="btn btn-primary" href="/surveys/add?questiontype=radio&referer=false&questionnaire_id={{$Questionnaire['id']}}"><i class="fa fa-plus"></i> 单选</a>
	<a onclick="return publishController.open_dialog(this.href,{id:'questionnaire-form',title:'新增多选表单项','width':'860px',submitCallback:function(){reloadQuestionList();}});" class="btn btn-primary" href="/surveys/add?questiontype=checkbox&referer=false&questionnaire_id={{$Questionnaire['id']}}"><i class="fa fa-plus"></i> 多选</a>
	<!-- <a onclick="return publishController.open_dialog(this.href,{title:'新增下拉选择表单项','width':'860px'});" class="btn btn-primary" href="/surveys/add?questiontype=select&questionnaire_id={{$Questionnaire['id']}}"><i class="fa fa-plus"></i> 下拉选择</a> -->
	<a onclick="return publishController.open_dialog(this.href,{id:'questionnaire-form',title:'新增问答表单项','width':'860px',submitCallback:function(){reloadQuestionList();}});" class="btn btn-primary" href="/surveys/add?questiontype=textarea&referer=false&questionnaire_id={{$Questionnaire['id']}}"><i class="fa fa-plus"></i> 问答</a>
	
	<hr>
	
	<div id="survey_question_list">
			<div id="survey_question_list_inner">{{$question_list}}</div>
	</div>
<script type="text/javascript" src="/js/jquery/jquery-ui-1.10.3.custom.min.js"></script>
<script>

function sortQuestion(){
	try{
		$("#q_list").sortable( "destroy" );
	}
	catch(e){
		;
	}
	
	$("#q_list").sortable({
		update: function(event, ui) {
			var orders = $(this).sortable('serialize');
//			alert(orders);
			ajaxAction('/tools/sortItem?questionnaire_id={{$Questionnaire['id']}}&field_name=survey_id',orders);			
		},
		placeholder: 'ui-state-highlight'
	});
	$("#q_list").disableSelection();
}

function reloadQuestionList(){
	publishController.close_dialog();
	$('#survey_question_list').load('/questionnaires/editform/{{$Questionnaire['id']}} #survey_question_list',function(){
		sortQuestion();
	});
}

$(function(){
	$('#survey_question_list input,#survey_question_list textarea').attr('disabled','disabled');
	
	sortQuestion();
})

</script>

<hr>
<div>
	{{$Questionnaire['content']}}
</div>